{% extends 'demo/base.html' %}
{% load common_extras %}
{% load static %}
{% block title %}
    {{ now_classes|capfirst }}博客-{{ block.super }}
{% endblock %}
{% block header %}
    {% include 'demo/header.html' %}
{% endblock %}
{% block link %}
    <link rel="stylesheet" href="{% static 'css/demo/user_article.css'%}">
    {{ block.super }}
{% endblock %}
{% block main %}

    {% if pages %}
        <ul class="navs">
        {% for article in pages %}
            <li>
                <div class="left">
                    <a href="/demo/article/{{ article.id }}/">
                        <h4>{{ forloop.counter }}、{{ article.title }}</h4>
                    </a>
                    <a href="/demo/article/{{ article.id }}/" class="desc">
                        {{ article.desc }}
                    </a>
                    {#                    <p class="info">于{{ article.create_time|date:'Y年m月d日H:i:s' }}发布</p>#}
                    <p class="info">于{{ article.create_time|time_since }}发布</p>
                    <div class="func">
                        <a href="/demo/article/update/{{ article.id }}">修改</a>
                        <a href="/demo/article/delete/{{ article.id }}">删除</a>
                    </div>
                </div>
                <div class="right">
                    <img src="/media/{{ article.cover }}" alt="">
                </div>
            </li>

        {% endfor %}
        <div class="bottom-info">
            {#        判断是否有上一页#}
            {% if pages.has_previous %}
                <a href="{% url 'ArticleUser' %}?page={{ pages.previous_page_number }}">上一页</a>
            {% endif %}
            {% for num in pages.paginator.page_range %}
                {#            如果点击显示的是当前页面#}
                {% if num == pages.number %}
                    <a href="{% url 'ArticleUser' %}?page={{ num }}" style="border-bottom: #5094d5 2px solid">{{ num }}</a>
                {% else %}
                    <a href="{% url 'ArticleUser' %}?page={{ num }}">{{ num }}</a>
                {% endif %}
            {% endfor %}
            {#        判断是否没有下一页#}
            {% if not pages.has_next %}
                <div class="bottom-info">文章已经是最后一篇了！！！</div>
            {% endif %}
            {#        判断是否有下一页#}
            {% if pages.has_next %}
            <a href="{% url 'ArticleUser' %}?page={{ pages.next_page_number }}">下一页</a>
            {% endif %}

        </div>

    {% else %}
        <div class="bottom-info">该分类暂时没有文章内容~</div>
    {% endif %}
</ul>
{% endblock %}
